//
//  NewsNavigation.m
//  Fireball
//
//  Created by 俞渊华 on 2017/12/18.
//  Copyright © 2017年 俞渊华. All rights reserved.
//

#import "NewsNavigation.h"

@interface NewsNavigation ()
@property(nonatomic, strong)UIButton *headerButton;
@property(nonatomic, strong)UILabel *nickNameLabel;
@property(nonatomic, strong)UIButton *attentionButton;
@end

@implementation NewsNavigation

-(instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        
        self.headerButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.headerButton.clipsToBounds = YES;
        self.headerButton.layer.cornerRadius = 32 * 0.5;
        [self addSubview:self.headerButton];
        self.headerButton.backgroundColor = [UIColor xm_MainColor];
        
        self.nickNameLabel = [[UILabel alloc]init];
        self.nickNameLabel.font = [UIFont xm_font:14.0];
        self.nickNameLabel.textColor = [UIColor xm_middleColor];
        [self addSubview:self.nickNameLabel];
        
        self.attentionButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.attentionButton setTitle:@"+关注" forState:UIControlStateNormal];
        [self.attentionButton setTitleColor:[UIColor xm_MainColor] forState:UIControlStateNormal];
        self.attentionButton.titleLabel.font = [UIFont xm_font:13.0];
        self.attentionButton.clipsToBounds = YES;
        self.attentionButton.layer.cornerRadius = 2.0;
        self.attentionButton.layer.borderWidth = 0.8;
        self.attentionButton.layer.borderColor = [UIColor xm_MainColor].CGColor;
        [self addSubview:self.attentionButton];
    }
    return self;
}

-(void)setModel:(AticleDetailModel *)model{
    _model = model;
    self.nickNameLabel.text = _model.Author;
    [self.headerButton xm_setImageWithURL:_model.UserLogo forState:UIControlStateNormal placeholderImage:nil];

}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    [self.nickNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(self);
    }];
    [self.headerButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.right.mas_equalTo(self.nickNameLabel.mas_left).offset(-10);
        make.size.mas_equalTo(CGSizeMake(32, 32));
    }];
    [self.attentionButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.left.mas_equalTo(self.nickNameLabel.mas_right).offset(10);
        make.size.mas_equalTo(CGSizeMake(60, 24));
    }];
}
-(void)drawRect:(CGRect)rect{
    [super drawRect:rect];
}


@end
